/// <summary>
/// 小人的关节控制脚本
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class JointControl : MonoBehaviour
{
    public Slider slider;
    private GameObject mixamorig_RightArm;
    private GameObject mixamorig_RightForeArm;
    private GameObject mixamorig_RightHand;
    private Quaternion targetQuaternion = Quaternion.Euler(0, 0, 0);
    private float speed = 1f;
    private float jointPos;
    public Animation handAnimation;

    // Start is called before the first frame update
    void Start()
    {
        mixamorig_RightArm = GameObject.Find("mixamorig:RightArm");
        mixamorig_RightForeArm = GameObject.Find("mixamorig:RightForeArm");
        mixamorig_RightHand = GameObject.Find("mixamorig:RightHand");
        //animation = GetComponent<Animation>();
    }

    // Update is called once per frame
    void Update()
    {


    }
    /// <summary>
    /// 抬起手臂
    /// </summary>
    public void onAction1()
    {
        handAnimation["raiseHand"].speed = 1;
        handAnimation.Play("raiseHand");
        Debug.Log("onAction1");

    }
    /// <summary>
    /// 放下手臂
    /// </summary>
    public void onAction2()
    {
        handAnimation["raiseHand"].speed = -1;
        handAnimation["raiseHand"].time = handAnimation["raiseHand"].length;
        handAnimation.Play("raiseHand");

        Debug.Log("onAction2");

    }
    /// <summary>
    /// 滑块控制手臂
    /// </summary>
    public void onSliderChanged()
    {
        // Debug.Log("onSliderChanged:");
        mixamorig_RightForeArm.transform.localRotation = Quaternion.Slerp(Quaternion.Euler(0, 0, 0), Quaternion.Euler(0, -90, 0), slider.value);

    }
}
